<template>
  <div class="contrast-box activity">
    <div class="contrast">
      <ul class="c-navTab">
        <li v-for="(item,index) in tabs" :class="{active:index == num}" @click="tab(index)" :key="index">
          {{item}}
        </li>
      </ul>
      <div class="c-main-box-box">
        <div class="c-main-box" v-bind:class="{translateX: num===1}">
          <div class="c-main">
            <div class="c-left">
              <div class="filter-box">
                <div class="title-date">
                  <h3 class="title">
                    <em></em>园所
                    <span>睡眠情况</span>横向对比</h3>
                  <ul>
                    <li class="btn1 on" @click="timeSlot(7, 311)">最近7天</li>
                    <li class="btn1" @click="timeSlot(30, 311)">最近30天</li>
                    <li>
                      <date-picker @getData="getData(arguments, 311)"></date-picker>
                    </li>
                  </ul>
                </div>
              </div>
              <ul>
                <li>
                  <div class="echarts-box">
                    <bar v-if="compareSleep.summary !== '暂无总结'" :settings="compareSleep"></bar>
                    <no-data v-else :item="'睡眠情况'" />
                  </div>
                  <el-summary :data="compareSleep.summary"></el-summary>
                </li>
                <li class="aRow">
                  <div>
                    <h3>状态选择（单选）</h3>
                    <el-radio :tabList="state" @getRadio="getRadio(arguments, 311.2)"></el-radio>
                  </div>
                  <div class="echarts-box">
                    <bar v-if="compareSleepState.summary !== '暂无总结'" :settings="compareSleepState"></bar>
                    <no-data v-else :item="'睡眠情况'" />
                  </div>
                  <el-summary :data="compareSleepState.summary"></el-summary>
                </li>
              </ul>
            </div>
            <div class="c-right">
              <div class="filter-box">
                <div class="title-date">
                  <h3 class="title">
                    <em></em>园所
                    <span>睡眠情况</span>纵向对比</h3>
                  <ul>
                    <li class="btn1 on" @click="timeSlot(90, 312)">最近3个月</li>
                  </ul>
                </div>
                <div>
                  <h3>年级选择（单选）</h3>
                  <el-radio :tabList="grade" @getRadio="getRadio(arguments, 312.2)"></el-radio>
                </div>
              </div>
              <div class="echarts-box">
                <div style="visibility: hidden;height:0px;">{{monthSleep.data}}</div>
                <pie3 v-if="monthSleep.summary !== '暂无总结'" :data="monthSleep.data"></pie3>
                <no-data v-else :item="'睡眠情况'" />
              </div>
              <el-summary :data="monthSleep.summary"></el-summary>
            </div>
          </div>
          <div class="c-main c-main-second">
            <div class="c-left">
              <div class="filter-box">
                <div class="title-date">
                  <h3 class="title">
                    <em></em>园所
                    <span>运动情况</span>横向对比</h3>
                  <ul>
                    <li class="btn1 on" @click="timeSlot(7, 321)">最近7天</li>
                    <li class="btn1" @click="timeSlot(30, 321)">最近30天</li>
                    <li>
                      <date-picker @getData="getData(arguments, 321)"></date-picker>
                    </li>
                  </ul>
                </div>
              </div>
              <div class="echarts-box">
                <bars :xData="compareActiveState.xData" :data="compareActiveState.data" :yName="compareActiveState.yName"
                  :grid="{
                      top: '15%',
                      left: '0%',
                      right: '0%',
                      bottom: '5%',
                      containLabel: true
                  }"
                  v-if="compareActiveState.summary !== '暂无总结'"
                ></bars>
                <no-data v-else :item="'运动情况'" />
              </div>
              <el-summary :data="compareActiveState.summary"></el-summary>
            </div>
            <div class="c-right">
              <div class="filter-box">
                <div class="title-date">
                  <h3 class="title">
                    <em></em>园所
                    <span>运动情况</span>纵向对比</h3>
                  <ul>
                    <li class="btn1 on" @click="timeSlot(90, 322)">最近3个月</li>
                  </ul>
                </div>
                <div>
                  <h3>年级选择（单选）</h3>
                  <el-radio :tabList="grade" @getRadio="getRadio(arguments, 322.2)"></el-radio>
                </div>
              </div>
              <div class="echarts-box">
                <div style="visibility: hidden;height:0px;">{{monthSport.data}}</div>
                <pie3 v-if="monthSport.summary !== '暂无总结'" :data="monthSport.data"></pie3>
                <no-data v-else :item="'运动情况'" />
              </div>
              <el-summary :data="monthSport.summary"></el-summary>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* eslint-disable */
import { mapGetters } from 'vuex'
import DatePicker from '@/common/elementUi/EldatePicker'
import ElRadio from '@/common/elementUi/ElRadio'
import ElLine from '@/common/echarts/Line'
import Bar from '@/common/echarts/Bar'
import MonthRange from '@/common/layerUi/MonthRange'
import BarBar from '@/common/echarts/expand/BarBar'
import Bars from '@/common/echarts/expand/Bars'
import { timeSlot } from '@/common/customTime/customTime'
import http from '@/common/axios/http'
import api from '@/common/axios/api'
import ElSummary from '@/common/summary/Summary'
import Pie3 from '@/common/echarts/expand/Pie3'
export default {
  name: 'HealthyContrast',
  components: {
    DatePicker,
    ElRadio,
    ElLine,
    MonthRange,
    BarBar,
    Bars,
    Bar,
    Pie3,
    ElSummary
  },
  data () {
    return {
      tabs: ['睡眠情况', '运动情况'],
      num: 0,
      grade: ['全年级', '托班', '小班', '中班', '大班'],
      state: ['基本没睡的儿童', '睡眠较少的儿童', '睡眠正常的儿童', '睡眠充足的儿童'],
      stateS: ['运动强度低', '运动强度中', '运动强度高'],
      // 首次登陆
      isOnce: true,
      // 睡眠情况横向对比
      sleepC: {
        time: {
          startTime: '2018-07-29',
          endTime: '2018-07-30'
        },
        grade: ['托班'],
        state: '基本没睡',
        data: []
      },
      // 睡眠情况纵向对比
      sleepL: {
        time: {
          startTime: '2018-07-29',
          endTime: '2018-07-30'
        },
        city: null,
        grade: '全年级',
        data: []
      },
      // 运动情况横向对比
      sportC: {
        time: {
          startTime: '2018-07-29',
          endTime: '2018-07-30'
        },
        grade: ['托班'],
        state: '运动强度低',
        data: []
      },
      // 运动情况纵向对比
      sportL: {
        time: {
          startTime: '2018-07-29',
          endTime: '2018-07-30'
        },
        city: null,
        grade: '全年级',
        data: []
      },
      // 各市园所睡眠情况横向对比-年级选择
      compareSleep: {
        xData: ['无数据'],
        maxVal: 0,
        data: [0],
        linearGradient: ['#53e9ee', '#325fff'],
        hasLine: false,
        yName: '睡眠时长（分）',
        grid: {
          top: '20%',
          left: '0%',
          right: '0%',
          bottom: '0%',
          containLabel: true
        },
        summary: '...'
      },
      // 各市园所睡眠情况横向对比
      compareSleepState: {
        xData: ['无数据'],
        maxVal: 0,
        data: ['0'],
        linearGradient: ['#53e9ee', '#325fff'],
        hasLine: false,
        yName: '儿童人数 (个)',
        grid: {
          top: '20%',
          left: '0%',
          right: '0%',
          bottom: '0%',
          containLabel: true
        },
        summary: '....'
      },
      compareActiveState: {
        xData: ['暂无数据'],
        data: [
          {
            name: '无数据',
            value: [0]
          }
        ],
        grid: {
          top: '5%',
          left: '0%',
          right: '0%',
          bottom: '0%',
          containLabel: true
        },
        yName: '各市园所儿童运动情况横向对比',
        summary: '.....'
      },
      // 各市园所睡眠情况纵向对比
      monthSleep: {
        xData: ['基本没睡', '睡眠较少', '睡眠正常', '睡眠充足'],
        data: [],
        labelNuit: '{c}人'
      },
      // 各市园所运动情况横向对比
      sportState: {
        xData: [],
        data: [{
          value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        }],
        yName: '人数（人）',
        color: ['#ffe98f']
      },
      // 各市园所运动情况纵向对比
      monthSport: {
        xData: ['运动强度低', '运动强度低', '运动强度低'],
        data: [],
        labelNuit: '{c}人'
      }
    }
  },
  computed: {
    provinceId () { return this.$store.getters.crumbIds.province },
    cityId () { return this.$store.getters.crumbIds.city },
    districtId () { return this.$store.getters.crumbIds.district },
    gardenName () { return this.$store.getters.crumbs.garden },
    gardenId () { return this.$store.getters.crumbIds.garden },
    ...mapGetters({
      // 当前区域名称
      areaName: 'area',
      // 区域等级
      areaLevel: 'areaLevel',
      // 选择对比项
      cityList: 'areaMapList'
    })
  },
  async mounted () {
    // 初始化所有边框样式
    this.$common.border(window.$('.contrast'))
    
    await this.$store.dispatch('fetchMapFeatures')

    this.sleepL.city = this.cityList[0]
    this.sportL.city = this.cityList[0]
    this.sportState.xData = this.cityList

    this.timeSlot(7, 311)
    this.timeSlot(90, 312)
    window.$('.title-date li').click(function () {
      window.$(this).closest('li').addClass('on').siblings().removeClass('on')
    })
  },
  watch: {
    // 睡眠情况横向对比
    'sleepC.time': {
      deep: true,
      handler: function (newVal) {
        this.getSleepC(newVal)
        this.daySleepC(newVal)
      }
    },
    'sleepC.state': {
      deep: true,
      handler: function (newVal) {
        this.daySleepC(this.sleepC.time)
      }
    },
    // 睡眠情况纵向对比
    'sleepL.time': {
      deep: true,
      handler: function (newVal) {
        this.getSleepL(newVal)
      }
    },
    'sleepL.grade': {
      deep: true,
      handler: function (newVal) {
        this.getSleepL(newVal)
      }
    },
    // 运动情况横向对比
    'sportC.time': {
      deep: true,
      handler: function (newVal) {
        this.getSportC(newVal)
      }
    },
    'sportC.grade': {
      deep: true,
      handler: function (newVal) {
        this.getSportC(this.sportC.time)
      }
    },

    // 运动情况纵向对比
    'sportL.time': {
      deep: true,
      handler: function (newVal) {
        this.getSportL(newVal)
      }
    },
    'sportL.grade': {
      deep: true,
      handler: function (newVal) {
        this.getSportL(this.sportL.time)
      }
    }
  },
  methods: {
    // 睡眠情况横向对比
    getSleepC: async function (newVal) {
      const result = await http.get(api.getSleepCompare, {
        firstDateTime: newVal.startTime,
        lastDateTime: newVal.endTime,
        gardenId: this.gardenId,
      })
      const res = result.data.data
      console.log(res,'shuimian')
      let summary1 = ''
      if (res.length) {
        const defaultObj = {
          gradeNum: 0,
          averageSleepTime: 0
        }
        for (let i = 0; i < res.length; i++) {
          res[i] = window.$.extend({}, defaultObj, res[i])
        }
        for (let i = 0, len = res.length; i < len; i++) {
          if (res[i].gradeNum === 1) {
            res[i].name = '托班'
          } else if (res[i].gradeNum === 2) {
            res[i].name = '小班'
          } else if (res[i].gradeNum === 3) {
            res[i].name = '中班'
          } else if (res[i].gradeNum === 4) {
            res[i].name = '大班'
          }
        }
        const resultData = res.filter((item) => {
          return (item.name && (item.averageSleepTime !== 0))
        })
        if (resultData.length) {
          resultData.sort(function (a, b) {
            return b.averageSleepTime - a.averageSleepTime
          })
          let classSleepName = []
          let classSleepValues = []
          for (let i = 0; i < resultData.length; i++) {
            classSleepName.push(resultData[i].name)
            classSleepValues.push(resultData[i].averageSleepTime)
          }
          summary1 = `该园所在${this.sleepC.time.startTime}到${this.sleepC.time.endTime}中睡眠对比情况如下:<br>平均睡眠时长最长的是:${resultData[0].name} 平均睡眠时长最短的是:${resultData[resultData.length - 1].name}`
          this.compareSleep.xData = classSleepName
          this.compareSleep.data = classSleepValues
          this.compareSleep.maxVal = Math.max(...classSleepValues)
          this.compareSleep.summary = summary1
        } else {
          this.compareSleep.xData = ['无数据']
          this.compareSleep.data = ['0']
          this.compareSleep.maxVal = 0
          this.compareSleep.summary = '暂无总结'
        }
      } else {
        this.compareSleep.xData = ['无数据']
        this.compareSleep.data = ['0']
        this.compareSleep.maxVal = 0
        this.compareSleep.summary = '暂无总结'
      }
    },
    // 睡眠状态横向对比
    daySleepC: async function (newVal) {
      // console.log(this.sleepC.state)
      if (this.sleepC.state == '基本没睡的儿童') {
        this.sleepC.state = '基本没睡'
      } else if (this.sleepC.state == '睡眠较少的儿童') {
        this.sleepC.state = '睡眠少'
      } else if (this.sleepC.state == '睡眠正常的儿童') {
        this.sleepC.state = '正常'
      } else if (this.sleepC.state == '睡眠充足的儿童') {
        this.sleepC.state = '睡眠多'
      }
      console.log(this.sleepC.state)
      const result = await http.get(api.getSleepState, {
        firstDateTime: newVal.startTime,
        lastDateTime: newVal.endTime,
        qualityType: this.sleepC.state,
        gardenId: this.gardenId,
      })
      // console.log(this.sleepC.state)
      // console.log(result)
      const res = result.data.data
      let summary2 = ''
      if (res.length) {
        const defaultObj = {
          gradeNum: 0,
          count: 0
        }
        for (let i = 0; i < res.length; i++) {
          res[i] = window.$.extend({}, defaultObj, res[i])
        }
        for (let i = 0, len = res.length; i < len; i++) {
          if (res[i].gradeNum === 1) {
            res[i].name = '托班'
          } else if (res[i].gradeNum === 2) {
            res[i].name = '小班'
          } else if (res[i].gradeNum === 3) {
            res[i].name = '中班'
          } else if (res[i].gradeNum === 4) {
            res[i].name = '大班'
          }
        }
        const resultData = res.filter((item) => {
          return (item.name && (item.count !== 0))
        })
        if (resultData.length) {
          resultData.sort(function (a, b) {
            return b.count - a.count
          })
          let classSleepStateName = []
          let classSleepStateValues = []
          for (let i = 0; i < resultData.length; i++) {
            classSleepStateName.push(resultData[i].name)
            classSleepStateValues.push(resultData[i].count)
          }
          summary2 = `在该园所内:${this.sleepC.state}最多的班级是:${resultData[0].name}`
          this.compareSleepState.xData = classSleepStateName
          this.compareSleepState.data = classSleepStateValues
          this.compareSleepState.maxVal = Math.max(...classSleepStateValues) + 2
          this.compareSleepState.summary = summary2
        } else {
          this.compareSleepState.xData = ['无数据']
          this.compareSleepState.data = ['0']
          this.compareSleepState.maxVal = 0
          this.compareSleepState.summary = '暂无总结'
        }
      } else {
        this.compareSleepState.xData = ['无数据']
        this.compareSleepState.data = ['0']
        this.compareSleepState.maxVal = 0
        this.compareSleepState.summary = '暂无总结'
      }
    },
    // 睡眠情况纵向对比
    getSleepL: async function (newVal) {
      let gradeNum = null
      if (newVal === '全年级') {
        gradeNum = -1
      } else if (newVal === '托班') {
        gradeNum = 1
      } else if (newVal === '小班') {
        gradeNum = 2
      } else if (newVal === '中班') {
        gradeNum = 3
      } else if (newVal === '大班') {
        gradeNum = 4
      }
      const result = await http.get(api.getSleepStateCount, {
        firstDateTime: this.sleepL.time.startTime,
        lastDateTime: this.sleepL.time.endTime,
        gradeNum,
        gardenId: this.gardenId
      })
      const res = result.data.data
      if (res.length) {
        const defaultObj = {
          date: '',
          noSleep: 0,
          lessSleep: 0,
          normalSleep: 0,
          moreSleep: 0
        }
        for (let i = 0; i < res.length; i++) {
          res[i] = window.$.extend({}, defaultObj, res[i])
        }
        let arr = []
        for (let i = 0; i < res.length; i++) {
          arr.push({
            title: res[i].date.substring(0, 7) + '月',
            data: [
              { value: res[i].noSleep, name: '基本没睡' },
              { value: res[i].lessSleep, name: '睡眠较少' },
              { value: res[i].normalSleep, name: '睡眠正常' },
              { value: res[i].moreSleep, name: '睡眠充足' }
            ]
          })
        }
        this.monthSleep.data = arr
      } else {
        let arr = [{
          title: '暂无数据',
          data: [
            { value: 0, name: '暂无数据' }
          ]
        }]
        this.monthSleep.data = arr
      }
      // 总结语
      let summary = ''
      if (res.length) {
        const summarySort = {
          '基本没睡': this.$common.compareSort(res, 'noSleep'),
          '睡眠较少': this.$common.compareSort(res, 'lessSleep'),
          '睡眠正常': this.$common.compareSort(res, 'normalSleep'),
          '睡眠充足': this.$common.compareSort(res, 'moreSleep')
        }
        let garde = ''
          
        switch (this.sleepL.garde) {
          case -1:
            garde = '全年级'
            break
          case 1:
            garde = '托班'
            break
          case 2:
            garde = '小班'
            break
          case 3:
            garde = '大班'
            break
        }
        summary = this.gardenName + garde + '在最近3个月的睡眠情况如下：<br>基本没睡人数最多：' + summarySort['基本没睡'][0].date.substring(0, 7) + '的' + summarySort['基本没睡'][0].noSleep + '人 基本没睡人数最少：' + summarySort['基本没睡'][summarySort['基本没睡'].length - 1].date.substring(0, 7) + '的' + summarySort['基本没睡'][summarySort['基本没睡'].length - 1].noSleep + '人<br>' + '睡眠较少人数最多：' + summarySort['睡眠较少'][0].date.substring(0, 7) + '的' + summarySort['睡眠较少'][0].lessSleep + '人 基睡眠较少人数最少：' + summarySort['睡眠较少'][summarySort['睡眠较少'].length - 1].date.substring(0, 7) + '的' + summarySort['睡眠较少'][summarySort['睡眠较少'].length - 1].lessSleep + '人<br>' + '睡眠正常人数最多：' + summarySort['睡眠正常'][0].date.substring(0, 7) + '的' + summarySort['睡眠正常'][0].normalSleep + '人 睡眠正常人数最少：' + summarySort['睡眠正常'][summarySort['睡眠正常'].length - 1].date.substring(0, 7) + '的' + summarySort['睡眠正常'][summarySort['睡眠正常'].length - 1].normalSleep + '人<br>' + '睡眠充足人数最多：' + summarySort['睡眠充足'][0].date.substring(0, 7) + '的' + summarySort['睡眠充足'][0].moreSleep + '人 睡眠充足人数最少：' + summarySort['睡眠充足'][summarySort['睡眠充足'].length - 1].date.substring(0, 7) + '的' + summarySort['睡眠充足'][summarySort['睡眠充足'].length - 1].moreSleep + '人' // eslint-disable-line
      } else {
        summary = '暂无总结'
      }
      this.monthSleep.summary = summary
    },
    getSportC: async function (newVal) {
      const result = await http.get(api.getSportState, {
        firstDateTime: newVal.startTime,
        lastDateTime: newVal.endTime,
        gardenId: this.gardenId
      })
      let res = result.data.data
      let summary1 = ''
      if (res.length) {
        const defaultObj = {
          gradeNum: 0,
          heavyCount: 0,
          lowerCount: 0,
          centerCount: 0
        }
        for (let i = 0; i < res.length; i++) {
          res[i] = window.$.extend({}, defaultObj, res[i])
        }
        for (let i = 0, len = res.length; i < len; i++) {
          if (res[i].gradeNum === 1) {
            res[i].name = '托班'
          } else if (res[i].gradeNum === 2) {
            res[i].name = '小班'
          } else if (res[i].gradeNum === 3) {
            res[i].name = '中班'
          } else if (res[i].gradeNum === 4) {
            res[i].name = '大班'
          }
        }
        console.log(res)
        let arr = []
        for (let i = 0; i < res.length; i++) {
          arr.push(res[i].name)
        }
        console.log(arr)
        // this.compareActiveState.xData = arr
        let arrayheavyCount = []
        let arraylowerCount = []
        let arraycenterCount = []
        for (let i = 0; i < res.length; i++) {
          arrayheavyCount.push(res[i].heavyCount)
          arraylowerCount.push(res[i].lowerCount)
          arraycenterCount.push(res[i].centerCount)
        }
        summary1 = `在该园所中,在${newVal.startTime}至${newVal.endTime}中, <br> 高强度最高的人数为:${Math.max(...arrayheavyCount)}人,最低的人数为:${Math.min(...arrayheavyCount)}人,
        <br>中强度最高的人数为:${Math.max(...arraycenterCount)}人,最低的人数为:${Math.min(...arraycenterCount)}人,<br> 低强度最高的人数为:${Math.max(...arraylowerCount)}人,最低的人数为: ${Math.min(...arraylowerCount)}人`
        console.log(arrayheavyCount, arraylowerCount, arraycenterCount)
        this.compareActiveState = {
          xData: arr,
          data: [
            {
              name: '高强度',
              value: arrayheavyCount
            },
            {
              name: '低强度',
              value: arraylowerCount
            },
            {
              name: '中强度',
              value: arraycenterCount
            }
          ],
          color: ['#53e9ee', '#ffe98f'],
          yName: '园所儿童运动情况横向对比',
          summary: summary1
        }
      } else {
        this.compareActiveState = {
          xData: ['暂无数据'],
          data:
            [
              {
                value: [0]
              }
            ],
          color: ['#53e9ee', '#ffe98f'],
          yName: '园所儿童运动情况横向对比',
          summary: '暂无总结'
        }
      }
    },
    // 运动情况纵向对比
    getSportL: async function (newVal) {
      if (this.sportL.grade === '全年级') {
        this.sportL.grade = -1
      } else if (this.sportL.grade === '托班') {
        this.sportL.grade = 1
      } else if (this.sportL.grade === '小班') {
        this.sportL.grade = 2
      } else if (this.sportL.grade === '中班') {
        this.sportL.grade = 3
      } else if (this.sportL.grade === '大班') {
        this.sportL.grade = 4
      }
      console.log(this.sportL.grade)
      const result = await http.get(api.getSportStateCount, {
        firstDateTime: newVal.startTime,
        lastDateTime: newVal.endTime,
        gradeNum: this.sportL.grade,
        gardenId: this.gardenId
      })
      const res = result.data.data
      // console.log(result)
      if (res.length) {
        const defaultObj = {
          date: '',
          heavyCount: 0,
          centerCount: 0,
          lowerCount: 0,
        }
        for (let i = 0; i < res.length; i++) {
          res[i] = window.$.extend({}, defaultObj, res[i])
        }
        let arr = []
        for (let i = 0; i < res.length; i++) {
          arr.push({
            title: res[i].date.substring(0, 7) + '月',
            data: [
              { value: res[i].lowerCount, name: '运动强度低' },
              { value: res[i].centerCount, name: '运动强度中' },
              { value: res[i].heavyCount, name: '运动强度高' }
            ]
          })
        }
        this.monthSport.data = arr
      } else {
        let arr = [{
          title: '暂无数据',
          data: [
            { value: 0, name: '暂无数据' }
          ]
        }]
        this.monthSport.data = arr
      }
      // 总结语
      let summary = ''
      if (res.length) {
        const summarySort = {
          '运动强度低': this.$common.compareSort(res, 'lowerCount'),
          '运动强度中': this.$common.compareSort(res, 'centerCount'),
          '运动强度高': this.$common.compareSort(res, 'heavyCount')
        }
        let garde = ''
        switch (this.sportL.garde) {
          case -1:
            garde = '全年级'
            break
          case '1':
            garde = '托班'
            break
          case '2':
            garde = '小班'
            break
          case '3':
            garde = '大班'
            break
        }
        summary = this.gardenName + garde + '在最近3个月的运动情况如下：<br>运动强度低人数最多：' + summarySort['运动强度低'][0].date + '的' + summarySort['运动强度低'][0].lowerCount + '人 运动强度低人数最少：' + summarySort['运动强度低'][summarySort['运动强度低'].length - 1].date + '的' + summarySort['运动强度低'][summarySort['运动强度低'].length - 1].lowerCount + '人<br>' + '运动强度中人数最多：' + summarySort['运动强度中'][0].date + '的' + summarySort['运动强度中'][0].centerCount + '人 运动强度中少人数最少：' + summarySort['运动强度中'][summarySort['运动强度中'].length - 1].date + '的' + summarySort['运动强度中'][summarySort['运动强度中'].length - 1].centerCount + '人<br>' + '运动强度高人数最多：' + summarySort['运动强度高'][0].date + '的' + summarySort['运动强度高'][0].heavyCount + '人 运动强度高人数最少：' + summarySort['运动强度高'][summarySort['运动强度高'].length - 1].date + '的' + summarySort['运动强度高'][summarySort['运动强度高'].length - 1].heavyCount + '人' // eslint-disable-line
      } else {
        summary = '暂无总结'
      }
      this.monthSport.summary = summary
    },
    // 对比数据标签切换
    tab (index) {
      this.num = index
      if (index === 1 && this.isOnce) {
        this.timeSlot(7, 321)
        this.timeSlot(90, 322)
        this.isOnce = !this.isOnce
      }
    },
    // 最近一段时间
    timeSlot (d, i) {
      const res = timeSlot(d)
      switch (i) {
        case 311:
          this.sleepC.time.startTime = res.t1
          this.sleepC.time.endTime = res.t2
          this.sleepC.time.startTime = res.t1
          this.sleepC.time.endTime = res.t2
          break
        case 312:
          this.sleepL.time.startTime = res.t1
          this.sleepL.time.endTime = res.t2
          break
        case 321:
          this.sportC.time.startTime = res.t1
          this.sportC.time.endTime = res.t2
          this.sportC.time.startTime = res.t1
          this.sportC.time.endTime = res.t2
          break
        case 322:
          this.sportL.time.startTime = res.t1
          this.sportL.time.endTime = res.t2
          break
      }
    },
    // 开始结束时间(天)
    getData (d, i) {
      const res = d[0]
      switch (i) {
        case 311:
          this.sleepC.time.startTime = res.t1
          this.sleepC.time.endTime = res.t2
          this.sleepC.time.startTime = res.t1
          this.sleepC.time.endTime = res.t2
          break
        case 321:
          this.sportC.time.startTime = res.t1
          this.sportC.time.endTime = res.t2
          this.sportC.time.startTime = res.t1
          this.sportC.time.endTime = res.t2
          break
      }
    },
    // 开始结束时间(月)
    getMonthRange (d, i) {
      const res = d[0]
      switch (i) {
        case 312:
          this.sleepL.time.startTime = res.t1
          this.sleepL.time.endTime = res.t2
          break
        case 322:
          this.sportL.time.startTime = res.t1
          this.sportL.time.endTime = res.t2
          break
      }
    },
    // 城市单选
    getRadio (d, i) {
      const res = d[0]
      switch (i) {
        case 311.1:
          this.sleepC.grade = res
          break
        case 311.2:
          this.sleepC.state = res
          break
        case 312.1:
          this.sleepL.city = res
          break
        case 312.2:
          this.sleepL.grade = res
          break
        case 321.1:
          this.sportC.grade = res
          break
        case 321.2:
          this.sportC.state = res
          break
        case 322.1:
          this.sportL.city = res
          break
        case 322.2:
          this.sportL.grade = res
          break
      }
    }
  }
}
</script>
<style lang="stylus" scoped>
.activity
  .c-left
    .filter-box
      margin 0 !important
    ul
      flex 1
      min-height: 1px
      li
        display flex
        flex-direction column
        height 50%
        .echarts-box
          margin-top 20px
  .c-right
    .filter-box > div:nth-child(2)
      margin-bottom 20px
</style>
<style>
.panzhipeng {
  height: 100px;
}
.aRow {
  margin-top: 10px;
}
</style>
